<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>创建合同订单</title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <c:set value="<%=ResourcesUtil.getConfig(\"audit_uncommit\") %>" var="audit_00"></c:set>
    <script type="text/javascript">
    /*  提交  */
    function commitAdvance(){
    	if (confirm("<spring:message code="purchaseAdvance_edit_areYouSureCommit"/>")) {
    		var id = $("#id").val();
    		var param = {"id":id};
    		$.post("${ctx}/purchase/advance/commit",param,function(result){
    			/* 弹出提示框,刷新父页面,关闭当前页面 */
    			tipParent(result.message);
    			 window.parent.frames[0].searchListForm();
    			closeWin();
    		},'json');
    	}
    }
    /* 删除  */
    function deleteAdvance(){
    	if (confirm("<spring:message code="purchaseAdvance_edit_areYouSureDelete"/>")) {
    		var id = $("#id").val();
    		var param = {"id":id};
    		$.post("${ctx}/purchase/advance/delete",param,function(result){
    			/* 弹出提示框,刷新父页面,关闭当前页面 */
    			tipParent(result.message);
    			 window.parent.frames[0].searchListForm();
    			closeWin();
    		},'json');
    	}
    }
    function excelExport() {
    	$("#inputForm").submit();
    }
    
    
    </script>
    <style type="text/css">
    .linkBox{
	color:#0a6dca;
	cursor:pointer;
	text-decoration:underline;
}
    </style>
</head>
<form id="inputForm" ACTION="${ctx}/purchase/advance/exportFile" method="post">
<input type="hidden" name="createBy.firstName" value="${purchaseAdvance.createBy.firstName }"/>
<input type="hidden" name="appDate" value="<fmt:formatDate value="${purchaseAdvance.appDate }" pattern="yyyy-MM-dd" />">
<input type="hidden" name="ognizationName" value="${purchaseAdvance.ognizationName}"/>
<input type="hidden" name="bankName" value="${purchaseAdvance.bankName}"/>
<input type="hidden" name="bankAccountNo" value="${purchaseAdvance.bankAccountNo}"/>
<input type="hidden" name="advanceAmount" value="${purchaseAdvance.advanceAmount}"/>
<input type="hidden" name="advanceRate" value="${purchaseAdvance.advanceRate}"/>
<input type="hidden" name="advanceDueDate" value="<fmt:formatDate value="${purchaseAdvance.advanceDueDate }" pattern="yyyy-MM-dd" />">

<body>   
<input type="hidden" id="id" name="id" value="${purchaseAdvance.id }">
<div id="createHead" class="layerHeader clearfix">
		<p class="headerTitle"><spring:message code="purchaseAdvance_edit_viewContract"/></p>
    <div class="headerButton clearfix">
    <!-- 预付款申请下载  -->
        <button type="button" onclick="excelExport();"><spring:message code="purchaseAdvance_edit_advanceDownload"/></button>
    <c:if test="${purchaseAdvance.deleteFlag == 0 }">
    	<c:if test="${purchaseAdvance.status == audit_00 }">
   	 	<!-- 提交按钮 -->
   	 	<shiro:hasPermission name="purchase:advance:edit">
    		<button type="button" onclick="commitAdvance();"><spring:message code="purchaseAdvance_edit_commit"/></button>
    	</shiro:hasPermission>
    	</c:if>
    	<c:if test="${purchaseAdvance.status != audit_00 }">
    	<!-- 审核按钮 -->
    	<shiro:hasPermission name="purchase:advance:audit">
    		<button type="button" onclick="popup('800px','519px','${ctx}/purchase/advance/audit?id=${purchaseAdvance.id }')"><spring:message code="purchaseAdvance_edit_audit"/></button>
    	</shiro:hasPermission>
    	</c:if>
    	<c:if test="${purchaseAdvance.status == audit_00 }">
    	<shiro:hasPermission name="purchase:advance:edit">
    	<!-- 删除按钮 -->
        	<button type="button" onclick="deleteAdvance();"><spring:message code="purchaseAdvance_edit_delete"/></button>
        <!-- 编辑按钮 -->
        	<button type="button" onclick="window.location.href='${ctx}/purchase/advance/editAdvance?id=${purchaseAdvance.id}'"><spring:message code="purchaseAdvance_edit_edit"/></button>
        </shiro:hasPermission>
        </c:if>
    </c:if>
        <!-- 取消按钮 -->
        <button type="button" onclick="closeWin()"><spring:message code="purchaseAdvance_edit_cancle"/></button>
   	</div>
</div>
<div id="showHtml" class="smOrderBox showHtml">
<div class=" clearfix" >
        	<p class="title" style="margin-top: 2px"><spring:message code="purchaseAdvance_edit_contractMessage"/></p>
        </div>
    <div class="items clearfix">
        <div class="col-33 clearfix haveToBox">
        <!-- 采购合同号 -->
            <p class="tit"><spring:message code="purchaseAdvance_edit_contractMaterialNO"/></p>
            <input type="text" value="${purchaseAdvance.contractMaterialNO }">
            <p class="haveTo">*</p>
        </div>
        <div class="col-33 clearfix haveToBox">
        <!-- 供货商  -->
            <p class="tit"><spring:message code="purchaseAdvance_edit_ognizationName"/></p>
             <input type="text" value="${purchaseAdvance.ognizationName }">
            <p class="haveTo">*</p>
        </div>
        
    </div>
    <div class="items clearfix">
        <div class="col-33 clearfix haveToBox">
        <!-- 申请日期  -->
            <p class="tit"><spring:message code="purchaseAdvance_edit_appDate"/></p>
            <input type="text" readonly="readonly" value="<fmt:formatDate value="${purchaseAdvance.appDate }" pattern="yyyy-MM-dd" />">
            <p class="haveTo">*</p>
        </div>
        <div class="col-33 clearfix haveToBox">
        <!-- 开户银行  -->
            <p class="tit"><spring:message code="purchaseAdvance_edit_bankName"/></p>
             <input type="text" value="${purchaseAdvance.bankName }">
            <p class="haveTo">*</p>
        </div>
        <div class="col-33 clearfix haveToBox">
        <!-- 银行账户  -->
            <p class="tit"><spring:message code="purchaseAdvance_edit_bankAccountNo"/></p>
            <input type="text" value="${purchaseAdvance.bankAccountNo }">
            <p class="haveTo">*</p>
        </div>
    </div>
    <div class="items clearfix" >        	
                <div class="col-33 clearfix haveToBox">
                <!-- 付款期限 -->
                    <p class="tit"><spring:message code="purchaseAdvance_edit_advanceDueDate"/></p>
                    <label><fmt:formatDate value="${purchaseAdvance.advanceDueDate }" pattern="yyyy-MM-dd" /></label>&ensp;前
                    <p class="haveTo">*</p>
                </div>
                
                <div class="col-33 clearfix haveToBox">
                <!-- 采购数量  -->
                    <p class="tit"><spring:message code="purchaseAdvance_edit_contractQuantity"/></p>
                    <input type="text" value="<fmt:formatNumber value="${purchaseAdvance.contractMaterialQuantity }"  pattern="#,##0.00#"/>">
                    <p class="haveTo">*</p>
                </div>
                <div class="col-33 clearfix haveToBox">
                <!-- 采购金额  -->
                    <p class="tit"><spring:message code="purchaseAdvance_edit_contractAmount"/></p>
                    <input type="text" value="<fmt:formatNumber value="${purchaseAdvance.contractAmount }"  pattern="#,##0.00#"/>">
                    <p class="haveTo">*</p>
                </div>
            </div>
    
            <div class="items clearfix haveToBox">        	
                <div class="col-33 clearfix">
                <!-- 预付款金额  -->
                    <p class="tit"><spring:message code="purchaseAdvance_edit_advanceAmount"/></p>
                    <input type="text" value="<fmt:formatNumber value="${purchaseAdvance.advanceAmount }"  pattern="#,##0.00#"/>">
           			<p class="haveTo">*</p>
                </div>
                <div class="col-33 clearfix haveToBox">
                <!-- 预付款比例  -->
                    <p class="tit"><spring:message code="purchaseAdvance_edit_advanceRate"/></p>
                    <input type="text" value="<fmt:formatNumber value="${purchaseAdvance.advanceRate }"  pattern="###0.00#"/>" style="width: 40px">
                    <span>&ensp;%</span>
                	<p class="haveTo">*</p>
                </div>
                <div class="col-33 clearfix haveToBox">
                <!-- 创建人员  -->
            		<p class="tit"><spring:message code="purchaseAdvance_edit_creator"/></p>
            		<input type="text" value="${purchaseAdvance.createBy.firstName }">
            		<p class="haveTo">*</p>
        		</div>
            </div>
            <div class="items clearfix showHtml">
                
        		<div class="clearfix">
        		<!-- 申请原因 -->
            		<p class="tit"><spring:message code="purchaseAdvance_edit_advanceReason"/></p>
            		<textarea style="width:790px;height: 60px">${purchaseAdvance.advanceReason }</textarea>
        		</div>
           
    </div>
    <div class=" clearfix" >
        	<p class="title" style="margin-top: 2px"><spring:message code="purchaseAdvance_edit_contractBasicMessage"/></p>
        </div>
</div>

<div class="tableArea">
    <div class="tableScrollSm" style="width: 968px;margin-left: 10px;overflow: auto;">
        <table cellpadding="0" class="tableHead">
            <thead>
            <tr>
                <th class="tab-wltp"><spring:message code="purchaseContract_edit_materailImage"/></th>
                <th class="tab-wlmcbj"><spring:message code="purchaseContract_edit_materailNameNO"/></th>
                <th class="tab-fk"><spring:message code="purchaseContract_edit_materailSpec"/></th>
                <th class="tab-dw"><spring:message code="purchaseContract_edit_materailSpecUnit"/></th>
                <th class="tab-hjje"><spring:message code="purchaseContract_edit_supplierName"/></th>
                <th class="tab-zdj"><spring:message code="purchaseContract_edit_contractNO"/></th>
                <th class="tab-zdj"><spring:message code="purchaseContract_edit_reserveQuantity"/></th>
                <th class="tab-jj"><spring:message code="purchaseContract_edit_realityQuantity"/></th>
                <th class="tab-jj"><spring:message code="purchaseContract_edit_unitPrice"/></th>
                <th class="tab-jj"><spring:message code="purchaseContract_edit_quantity"/></th>
                <th class="tab-jj"><spring:message code="purchaseContract_edit_otherCost"/></th>
                <th class="tab-jj"><spring:message code="purchaseContract_edit_amount"/></th>
                
            </tr>
            </thead>
        </table>
        <table cellpadding="0" class="tableBody" id="parentTable">
            <tbody id="sListHtml">
            <c:forEach items="${purchaseContract.materialList }" var="material" varStatus="status">
            <tr class="table-TR">
                <td class="tab-wltp"><c:if test="${material.materialFile!=null && material.materialFile!='' }"><img src="${material.materialFile }" class="tab-wltp"></c:if><c:if test="${material.materialFile==null||material.materialFile=='' }"><img src="${ctxStatic}/images/pic-none.jpg" class="tab-wltp"></c:if></td>
                        <td class="tab-wlmcbj">${material.materialCode }<br>${material.materialNameCN }</td>
                        <td class="tab-fk">${material.materialSpec }</td>
                        <td class="tab-dw">${fns:getDictName(material.materialSpecUnitCD) }</td>
                        <td class="tab-hjje">${material.ognizationNameB }</td>
                        <td class="tab-zdj">${material.contractNO }</td>
                        <td class="tab-zdj"><fmt:formatNumber value="${material.reserveQuantity }" pattern="#,##0.00"/></td>
                        <td class="tab-jj"><fmt:formatNumber value="${material.realityQuantity }" pattern="#,##0.00"/></td>
                        <td class="tab-jj"><fmt:formatNumber value="${material.purchaseUnitPrice }" pattern="#,##0.00"/></td>
                        <td class="tab-jj"><fmt:formatNumber value="${material.purchaseReserveQuantity }" pattern="#,##0.00"/></td>
                        <td class="tab-jj"><fmt:formatNumber value="${material.purchaseOtherCost }" pattern="#,##0.00"/></td>
                        <td class="tab-jj"><fmt:formatNumber value="${material.purchaseUnitPrice*material.purchaseReserveQuantity + material.purchaseOtherCost }" pattern="#,##0.00"/></td>
            			
            			<input type="hidden" name="materialList[${status.index}].materialCode" value="${material.materialCode}"/>
            			<input type="hidden" name="materialList[${status.index}].materialNameCN" value="${material.materialNameCN}"/>
            			<input type="hidden" name="materialList[${status.index}].purchaseUnitPrice" value="${material.purchaseUnitPrice}"/>
            			<input type="hidden" name="materialList[${status.index}].purchaseReserveQuantity" value="${material.purchaseReserveQuantity}"/>
            			<input type="hidden" name="materialList[${status.index}].purchaseAllCost" value="<fmt:formatNumber value="${material.purchaseUnitPrice*material.purchaseReserveQuantity + material.purchaseOtherCost }" pattern="0.#####"/>"/>
            </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
</form>
<script>
	window.onload = function(){
	$('.tableScrollSm').css('height','285px')
	$('td input').each(function(){
		var tdH = $(this).parents('td').height()
		$(this).css('height',tdH)
		})
	}
	var tableW = $('.tableHead').outerWidth();
	$('.tableScroll').css('width',tableW + 18 + 'px');
	$('.showHtml').find('input,select,textarea').attr('disabled','disabled');	
</script>
</body>
</html>
